<?php

class raw_address_dao extends dao
{
    protected $table_name = 'raw_address';
    protected $db_config_key = 'default';

    public function find_last_formated_by_estate_name_and_house_address_and_person_mobile_number($estate_name, $house_address, $person_mobile_number)
    {/*{{{*/
        if ($estate_name && $house_address && $person_mobile_number) {

            return $this->find_by_condition('
                estate_name = :estate_name
                and house_address = :house_address
                and person_mobile_number = :person_mobile_number
                and status = :status_formated
                and snap_formated_address_string <> ""
                order by id desc', 
                [
                    ':estate_name' => $estate_name,
                    ':house_address' => $house_address,
                    ':person_mobile_number' => $person_mobile_number,
                    ':status_formated' => raw_address::STATUS_FORMATED,
                ]);
        } else {

            return null_entity::create('raw_address');
        }
    }/*}}}*/
}
